package accs.model;

import accs.model.UserPasswordPair;

/**
 * A pair of username and password.
 * @author 
 */
public class UserPasswordPair {
	private String username;
	private String password;

	public UserPasswordPair(String username, String password) {
		setUsername(username);
		setPassword(password);
	}

	public UserPasswordPair() {
		this("","");
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		if(username==null) throw new NullPointerException("username is null");
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		if(password==null) throw new NullPointerException("password is null");
		this.password = password;
	}
	
	public boolean equals(Object obj) {
		if(!(obj instanceof UserPasswordPair)) return false;
		
		UserPasswordPair other=(UserPasswordPair)obj;
		
		return (other.username.equals(this.username) && other.password.equals(this.password));
	}
	
	public int hashCode() {
		return (username+password).hashCode();
	}
}